package com.mingshine.cloud.test;
 
 

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.UUID;
/**
 * @Class SendController
 * @Author 作者姓名:LiuXing
 * @Version 1.0
 * @Date 创建时间：2019-05-20 17:12
 * @Direction 类说明
 */
//@RestController
public class SendController {
 
    //直连方式 - direct 队列
    @Autowired
    private FirstDirectSender firstDirectSender;
 
    //广播方式 - fanout 队列
    @Autowired
    private FirstFanoutSender firstFanoutSender;
 
    //匹配方式 - topic 队列
    @Autowired
    private TopicSender topicSender ;
 
    /***
     * TODO 测试direct 直连的队列处理
     *
     * http://192.168.2.232:9081/directSend?message=call%20phone
     *
     * @param message
     * @return
     */
    @GetMapping("/directSend")
    public String directSend(String message){
        String uuid = UUID.randomUUID().toString();
        firstDirectSender.send(uuid,message);
        return uuid;
    }
 
    /***
     * TODO 测试fanout 广播的队列处理
     *
     * http://192.168.2.232:9081/fanoutSend?message=fanout%20go%20home
     *
     * @param message
     * @return
     */
    @GetMapping("/fanoutSend")
    public String fanoutSend(String message){
        String uuid = UUID.randomUUID().toString();
        firstFanoutSender.send( uuid,message );
        return uuid;
    }
 
 
    /***
     * TODO 测试topic 匹配的队列处理
     *
     * http://192.168.2.232:9081/topicSend?message=%E5%8C%B9%E9%85%8D%E6%A8%A1%E5%BC%8F%E9%80%9A%E7%9F%A5
     *
     * @param message
     * @return
     */
    @GetMapping("/topicSend")
    public String topicSend(String message){
        String uuid = UUID.randomUUID().toString();
        topicSender.send( uuid,message );
        return uuid;
    }
 
 
}